package org.hcyspartnoc.demo.pojo.vo.course;

import cn.hutool.core.bean.BeanUtil;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hcyspartnoc.demo.pojo.vo.system.SysRoleVo;

import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
public class CourseVo {
    private Integer id; // 匹配数据库中的id字段，注意这里使用Integer而不是int，以支持null值

    private String courseCode; // 课程编号

    private String courseName; // 课程名称

    private String courseEnname; // 课程英文名称

    private String collegeName; // 开课单位

    private String characterName; // 课程性质ID

    private String category; // 课程类别

    private Teacher director;

    private List<CouTeamMeb> couTeam; // 教学团队ID

    private String semester; // 授课学期

    private String credit; // 学分

    private String hours; // 学时

    private String inClassHours; // 课堂学时

    private String theoretical; // 理论授课

    private String inClassPractice; // 课堂实践

    private String computerHours; // 上机学时

    private String experimentalHours; // 实验学时

    private String outClassHours; // 课外学时

    private String majorName; // 适用专业ID

    private String bilingual; // 是否双语

    private List<CourseRelation> subsequent;

    private List<CourseRelation> preRepair;

    public void setPreRepairs(List<CouRelationVo> preRepairs) {
        this.preRepair = new ArrayList<>();
        for(CouRelationVo couRelationVo : preRepairs){
            CourseRelation courseRelation = new CourseRelation();
            courseRelation.setId(couRelationVo.getId());
            courseRelation.setName(couRelationVo.getCourseCode() + "-" + couRelationVo.getCourseName());
            this.preRepair.add(courseRelation);
        }
    }

    public void setDirector(CourseTeamVo courseTeamVo) {
        this.director = new Teacher();
        this.director.setId(courseTeamVo.getId());
        this.director.setName(courseTeamVo.getDirectorName());
    }

    public void setCouTeamMeb(List<CouTeamMebVo> couTeamMebVos) {
        this.couTeam = new ArrayList<>();
        for(CouTeamMebVo couTeamMebVo : couTeamMebVos){
            CouTeamMeb couTeamMeb = BeanUtil.copyProperties(couTeamMebVo, CouTeamMeb.class);
            this.couTeam.add(couTeamMeb);
        }
    }



    @Data
    @NoArgsConstructor
    public static class CourseRelation{
        private Integer id;
        private String name;
    }

    @Data
    @NoArgsConstructor
    public static class CouTeamMeb{
        private Integer id; // 团队成员主键ID

        private Integer teamId; // 团队ID

        private String memberName; // 教师名称
    }
    @Data
    @NoArgsConstructor
    public static class Teacher{
        private Integer id;
        private String name;
    }

    public void setSubsequents(List<CouRelationVo> courseRelations){
        this.subsequent = new ArrayList<>();
        for(CouRelationVo couRelationVo : courseRelations){
            CourseRelation courseRelation = new CourseRelation();
            courseRelation.setId(couRelationVo.getId());
            courseRelation.setName(couRelationVo.getCourseCode() + "-" + couRelationVo.getCourseName());
            this.subsequent.add(courseRelation);
        }
    }
}
